package me.jiatao.dagger2;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;

import java.util.List;

import javax.inject.Inject;

import me.jiatao.dagger2.component.DaggerDependenceComponent;
import me.jiatao.dagger2.component.DaggerMainActivityComponent;
import me.jiatao.dagger2.component.MainActivityComponent;
import me.jiatao.dagger2.model.Address;
import me.jiatao.dagger2.model.Student;
import me.jiatao.dagger2.module.MainActivityArgsModule;

public class DepenActivity extends AppCompatActivity {

    @Inject
    Student student;

    @Inject
    List<String> stringList;

    @Inject
    List<String> stringList2;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
//
        Address address = new Address();
        address.setCity("Jiangsu");
        address.setStreet("LuJia");
//        DaggerMainActivityComponent
//                .builder()
//                .mainActivityArgsModule(new MainActivityArgsModule(address))
//                .build().inject(this);


        MainActivityComponent mainActivityComponent = DaggerMainActivityComponent
                .builder()
                .mainActivityArgsModule(new MainActivityArgsModule(address))
                .build();

        DaggerDependenceComponent.
                builder()
                .mainActivityComponent(mainActivityComponent)
                .build()
                .inject(this);

    }

    public void setStudent(View view) {
        student.setName("jia");
        student.setAge(10);
        student.toString();

//        stringList.add("1");
//        stringList.add("2");
//        stringList.add("3");
//
//        stringList2.add("A");
//        stringList2.add("B");
//        stringList2.add("C");
//
//        for (String s : stringList) {
//            System.err.println(s);
//        }
//
//        for (String s : stringList2) {
//            System.err.println(s);
//        }
    }
}
